package com.xy.biz.rs.domain.converter;

import com.xy.biz.rs.domain.bo.RecordTemplateGroupBO;
import com.xy.biz.rs.domain.po.RecordTemplateGroupPO;
import com.xy.biz.rs.domain.req.SaveRecordTemplateGroupRequest;
import com.xy.biz.rs.domain.req.UpdateRecordTemplateGroupRequest;
import com.xy.biz.rs.domain.resp.GetRecordTemplateGroupResponse;
import com.xy.biz.rs.domain.resp.GetRecordTemplateItemResponse;
import com.xy.tool.util.BeanUtilsEx;

import java.util.Collection;
import java.util.List;

/**
 *
 *
 * @author zsp
 * @date 2022-1-4
 */
public class RecordTemplateGroupConverter {

	public static RecordTemplateGroupPO toPO(RecordTemplateGroupBO source) {
		return BeanUtilsEx.copyProperties(source, () -> new RecordTemplateGroupPO(), true);
	}

	public static List<RecordTemplateGroupPO> toPO(Collection<RecordTemplateGroupBO> source) {
		return BeanUtilsEx.copyPropertiesForNewList(source, () -> new RecordTemplateGroupPO(), true);
	}

	public static RecordTemplateGroupBO fromPO(RecordTemplateGroupPO source) {
		return BeanUtilsEx.copyProperties(source, () -> new RecordTemplateGroupBO());
	}

	public static List<RecordTemplateGroupBO> fromPO(Collection<RecordTemplateGroupPO> source) {
		return BeanUtilsEx.copyPropertiesForNewList(source, () -> new RecordTemplateGroupBO());
	}

	public static RecordTemplateGroupBO toBO(SaveRecordTemplateGroupRequest source) {
		return BeanUtilsEx.copyProperties(source, () -> new RecordTemplateGroupBO(), true);
	}

	public static RecordTemplateGroupBO toBO(UpdateRecordTemplateGroupRequest source) {
		return BeanUtilsEx.copyProperties(source, () -> new RecordTemplateGroupBO(), true);
	}

	public static List<RecordTemplateGroupBO> toBO(Collection<SaveRecordTemplateGroupRequest> source) {
		return BeanUtilsEx.copyPropertiesForNewList(source, () -> new RecordTemplateGroupBO(), true);
	}

	public static GetRecordTemplateGroupResponse toResponse(RecordTemplateGroupBO source) {
		return BeanUtilsEx.copyProperties(source,
				() -> new GetRecordTemplateGroupResponse(),
				(s, t) -> {
					t.setItemList(BeanUtilsEx.copyPropertiesForNewList(s.getItemList(), () -> new GetRecordTemplateItemResponse()));
				});
	}

	public static List<GetRecordTemplateGroupResponse> toResponse(Collection<RecordTemplateGroupBO> source) {
		return BeanUtilsEx.copyPropertiesForNewList(source,
				() -> new GetRecordTemplateGroupResponse(),
				(s, t) -> {
					t.setItemList(BeanUtilsEx.copyPropertiesForNewList(s.getItemList(), () -> new GetRecordTemplateItemResponse()));
				});
	}

}
